package c0907m.group2.aitsm.core.report;

import c0907m.group2.aitsm.util.Settings;

import java.util.List;

/**
 * Author: LongDH
 * Date: 5/6/11
 * Time: 4:01 PM
 * <p/>
 * Create report for Classes.
 */
public class FineReporter extends BaseReporter {
    public FineReporter() {
        this.filename = Settings.FINE_LIST_REPORT;
    }

    /**
     * Filter by Semester's id.
     *
     * @param id the list of ID to search.
     */
    public void hasSemesterIds(List<Integer> id) {
        StringBuilder ids = new StringBuilder();
        for (int i = 0; i < id.size(); i++) {
            ids.append(id.get(i));
            if (i < id.size() - 1) ids.append(",");
        }
        where += " AND semester_id IN (" + ids.toString() + ")";
    }

    /**
     * Filter by Student's id.
     *
     * @param id the ID to search.
     */
    public void hasStudentId(int id) {
        where += " AND student_id = " + id;
    }

    /**
     * Filter by semester's end year.
     *
     * @param year the year (yyyy) to search. Ex: 2011.
     */
    public void hasYear(int year) {
        where += " AND (DATEDIFF(year, start_date, '" + year + "') = 0";
        where += " OR DATEDIFF(year, end_date, '" + year + "') = 0)";
    }
}
